/*
 *  jOTR - Java Off-The-Record Messaging Library
 *  Copyright (C) 2007 Markus Karnik
 *
 *  This program is free software; you can redistribute it and/or modify it 
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation; either version 3 of the License, 
 *  or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 *  for more details.
 *
 *  You should have received a copy of the GNU General Public License along 
 *  with this program; if not, see <http://www.gnu.org/licenses/>.
 *  
 */

package de.karnik.libjotr;

/**
 * This class implements the jotr session key storage. It stores the hmac and aes keys for data message transmission.
 * 
 * @author Markus Karnik - markus.karnik@my-design.org
 * @version 1.0
 * @since 1.0
 */
public class JotrSessionKeys {

	/**
	 * Value to indicate if sending aes key was used.
	 */
	private boolean sendingUsed = false;
	/**
	 * Value to indicate if receiving aes key was used.
	 */
	private boolean receivingUsed = false;
    /**
     * The sending aes key.
     */
    private byte[] sendingAesKey = null;
    /**
     * The receiving aes key.
     */
    private byte[] receivingAesKey = null;
    /**
     * The sending mac key.
     */
    private byte[] sendingMacKey = null;
    /**
     * The receiving mac key.
     */
    private byte[] receivingMacKey = null;
    
	/**
	 * Constructor. Sets the initial keys. See otr protocol description for further informations.
	 * 
	 * @param sendingAesKey The initial sending aes key.
	 * @param receivingAesKey The initial receiving aes key.
	 * @param sendingMacKey The initial sending mac key.
	 * @param receivingMacKey The initial receiving mac key.
	 */
	public JotrSessionKeys( byte[] sendingAesKey, byte[] receivingAesKey, byte[] sendingMacKey, byte[] receivingMacKey ) {
		super();
		this.sendingAesKey = sendingAesKey;
		this.receivingAesKey = receivingAesKey;
		this.sendingMacKey = sendingMacKey;
		this.receivingMacKey = receivingMacKey;
	}

	/**
	 * Returns the sending aes key.
	 * 
	 * @return The sending aes key.
	 */
	public byte[] getSendingAesKey() {
		return sendingAesKey;
	}
	
	/**
	 * Sets the sending aes key.
	 * 
	 * @param sendingAesKey The sending aes key to set.
	 */
	public void setSendingAesKey( byte[] sendingAesKey ) {
		this.sendingAesKey = sendingAesKey;
	}
	
	/**
	 * Returns the sending mac key.
	 * 
	 * @return The sending mac key.
	 */
	public byte[] getSendingMacKey() {
		return sendingMacKey;
	}
	
	/**
	 * Sets the sending mac key.
	 * 
	 * @param sendingMacKey The sending mac key to set.
	 */
	public void setSendingMacKey( byte[] sendingMacKey ) {
		this.sendingMacKey = sendingMacKey;
	}
	
	/**
	 * Returns the receiving aes key.
	 * 
	 * @return The receiving aes key.
	 */
	public byte[] getReceivingAesKey() {
		return receivingAesKey;
	}
	
	/**
	 * Sets the receiving aes key.
	 * 
	 * @param receivingAesKey The receiving aes to set.
	 */
	public void setReceivingAesKey( byte[] receivingAesKey ) {
		this.receivingAesKey = receivingAesKey;
	}
	
	/**
	 * Returns the receiving mac key.
	 * 
	 * @return The receiving mac key
	 */
	public byte[] getReceivingMacKey() {
		return receivingMacKey;
	}
	
	/**
	 * Sets the receiving mac key.
	 * 
	 * @param receivingMacKey The receiving mac key to set.
	 */
	public void setReceivingMacKey( byte[] receivingMacKey ) {
		this.receivingMacKey = receivingMacKey;
	}

	/**
	 * Returns the sending key usage indicator.
	 * 
	 * @return <b>true</b> if the sending key was already used, <b>false</b> otherwise.
	 */
	public boolean isSendingUsed() {
		return sendingUsed;
	}

	/**
	 * Sets the usage of the sending key.
	 * 
	 * @param sendingUsed <b>true</b> if the sending key was already used, <b>false</b> otherwise.
	 */
	public void setSendingUsed(boolean sendingUsed) {
		this.sendingUsed = sendingUsed;
	}

	/**
	 * Returns the receiving key usage indicator.
	 * 
	 * @return <b>true</b> if the receiving key was already used, <b>false</b> otherwise.
	 */
	public boolean isReceivingUsed() {
		return receivingUsed;
	}

	/**
	 * Sets the usage of the receiving key.
	 * 
	 * @param recvUsed <b>true</b> if the receiving key was already used, <b>false</b> otherwise.
	 */
	public void setReceivingUsed(boolean recvUsed) {
		this.receivingUsed = recvUsed;
	}
}
